package com.ruoyi.quanzi.domain;

import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 帖子对象 sun_post
 * 
 * @author ruoyi
 * @date 2023-01-15
 */
public class SunPost extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 帖子ID */
    private Long id;

    /** 用户ID */
    @Excel(name = "用户ID")
    private Long uid;

    /** 圈子ID */
    @Excel(name = "圈子ID")
    private Long topicId;

    /** 话题ID */
    @Excel(name = "话题ID")
    private Long discussId;

    /** 投票ID */
    @Excel(name = "投票ID")
    private Long voteId;

    /** 帖子标题 */
    @Excel(name = "帖子标题")
    private String title;

    /** 帖子内容 */
    @Excel(name = "帖子内容")
    private String content;

    /** 帖子媒体文件 */
    @Excel(name = "帖子媒体文件")
    private String media;

    /** 阅读数 */
    @Excel(name = "阅读数")
    private Integer readCount;

    /** 是否置顶（0否 1是） */
    @Excel(name = "是否置顶", readConverterExp = "0=否,1=是")
    private Integer postTop;

    /** 帖子类型（1图文） */
    @Excel(name = "帖子类型", readConverterExp = "1=图文")
    private Integer type;

    /** 地址 */
    @Excel(name = "地址")
    private String address;

    /** 经度 */
    @Excel(name = "经度")
    private Double longitude;

    /** 纬度 */
    @Excel(name = "纬度")
    private Double latitude;

    /** 状态（0正常 1审核） */
    @Excel(name = "状态", readConverterExp = "0=正常,1=审核")
    private Integer status;

    /** 分类 */
    @Excel(name = "分类")
    private Integer cut;

    /** 是否已点赞（前端展示用） */
    private Boolean isLiked;

    /** 是否已收藏（前端展示用） */
    private Boolean isCollected;

    /** 评论列表（前端展示用） */
    private List<SunComment> comments;

    /** 用户名称（前端展示用） */
    private String username;

    /** 用户头像（前端展示用） */
    private String userAvatar;

    /** 圈子名称（前端展示用） */
    private String topicName;

    /** 点赞数（前端展示用） */
    private Integer likeCount;

    /** 评论数（前端展示用） */
    private Integer commentCount;

    /** 收藏数（前端展示用） */
    private Integer collectCount;

    /** 媒体列表（前端展示用） */
    private List<String> mediaList;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    
    // 兼容旧代码，将postId映射到id
    public void setPostId(Long postId)
    {
        this.id = postId;
    }
    
    // 兼容旧代码，将id作为postId返回
    public Long getPostId()
    {
        return id;
    }
    
    public void setUid(Long uid) 
    {
        this.uid = uid;
    }

    public Long getUid() 
    {
        return uid;
    }
    
    // 兼容旧代码，将userId映射到uid
    public void setUserId(Long userId)
    {
        this.uid = userId;
    }
    
    // 兼容旧代码，将uid作为userId返回
    public Long getUserId()
    {
        return uid;
    }
    
    public void setTopicId(Long topicId) 
    {
        this.topicId = topicId;
    }

    public Long getTopicId() 
    {
        return topicId;
    }
    
    // 兼容旧代码，将categoryId映射到topicId
    public void setCategoryId(Long categoryId)
    {
        this.topicId = categoryId;
    }
    
    // 兼容旧代码，将topicId作为categoryId返回
    public Long getCategoryId()
    {
        return topicId;
    }
    
    public void setDiscussId(Long discussId) 
    {
        this.discussId = discussId;
    }

    public Long getDiscussId() 
    {
        return discussId;
    }
    
    public void setVoteId(Long voteId) 
    {
        this.voteId = voteId;
    }

    public Long getVoteId() 
    {
        return voteId;
    }
    
    public void setTitle(String title) 
    {
        this.title = title;
    }

    public String getTitle() 
    {
        return title;
    }
    
    public void setContent(String content) 
    {
        this.content = content;
    }

    public String getContent() 
    {
        return content;
    }
    
    public void setMedia(String media) 
    {
        this.media = media;
        
        // 如果设置了media，尝试解析为mediaList
        if (media != null && !media.isEmpty()) {
            try {
                // 使用Jackson或其他JSON库解析
                com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
                this.mediaList = mapper.readValue(media, 
                    mapper.getTypeFactory().constructCollectionType(List.class, String.class));
            } catch (Exception e) {
                // 解析失败，忽略
            }
        }
    }

    public String getMedia() 
    {
        return media;
    }
    
    public void setReadCount(Integer readCount) 
    {
        this.readCount = readCount;
    }

    public Integer getReadCount() 
    {
        return readCount;
    }
    
    public void setPostTop(Integer postTop) 
    {
        this.postTop = postTop;
    }

    public Integer getPostTop() 
    {
        return postTop;
    }
    
    // 兼容旧代码，将isTop映射到postTop
    public void setIsTop(Integer isTop)
    {
        this.postTop = isTop;
    }
    
    // 兼容旧代码，将postTop作为isTop返回
    public Integer getIsTop()
    {
        return postTop;
    }
    
    public void setType(Integer type) 
    {
        this.type = type;
    }

    public Integer getType() 
    {
        return type;
    }
    
    public void setAddress(String address) 
    {
        this.address = address;
    }

    public String getAddress() 
    {
        return address;
    }
    
    public void setLongitude(Double longitude) 
    {
        this.longitude = longitude;
    }

    public Double getLongitude() 
    {
        return longitude;
    }
    
    public void setLatitude(Double latitude) 
    {
        this.latitude = latitude;
    }

    public Double getLatitude() 
    {
        return latitude;
    }
    
    public void setStatus(Integer status) 
    {
        this.status = status;
    }

    public Integer getStatus() 
    {
        return status;
    }
    
    public void setCut(Integer cut) 
    {
        this.cut = cut;
    }

    public Integer getCut() 
    {
        return cut;
    }
    
    public void setIsLiked(Boolean isLiked) 
    {
        this.isLiked = isLiked;
    }

    public Boolean getIsLiked() 
    {
        return isLiked;
    }
    
    public void setIsCollected(Boolean isCollected) 
    {
        this.isCollected = isCollected;
    }

    public Boolean getIsCollected() 
    {
        return isCollected;
    }
    
    public void setComments(List<SunComment> comments) 
    {
        this.comments = comments;
    }

    public List<SunComment> getComments() 
    {
        return comments;
    }

    public Boolean getLiked() {
        return isLiked;
    }

    public void setLiked(Boolean liked) {
        isLiked = liked;
    }

    public Boolean getCollected() {
        return isCollected;
    }

    public void setCollected(Boolean collected) {
        isCollected = collected;
    }
    
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
    
    // 兼容旧代码，将userName映射到username
    public void setUserName(String userName) {
        this.username = userName;
    }
    
    // 兼容旧代码，将username作为userName返回
    public String getUserName() {
        return username;
    }

    public String getUserAvatar() {
        return userAvatar;
    }

    public void setUserAvatar(String userAvatar) {
        this.userAvatar = userAvatar;
    }
    
    // 兼容旧代码，将avatar映射到userAvatar
    public void setAvatar(String avatar) {
        this.userAvatar = avatar;
    }
    
    // 兼容旧代码，将userAvatar作为avatar返回
    public String getAvatar() {
        return userAvatar;
    }

    public String getTopicName() {
        return topicName;
    }

    public void setTopicName(String topicName) {
        this.topicName = topicName;
    }
    
    // 兼容旧代码，将categoryName映射到topicName
    public void setCategoryName(String categoryName) {
        this.topicName = categoryName;
    }
    
    // 兼容旧代码，将topicName作为categoryName返回
    public String getCategoryName() {
        return topicName;
    }

    public Integer getLikeCount() {
        return likeCount;
    }

    public void setLikeCount(Integer likeCount) {
        this.likeCount = likeCount;
    }

    public Integer getCommentCount() {
        return commentCount;
    }

    public void setCommentCount(Integer commentCount) {
        this.commentCount = commentCount;
    }

    public Integer getCollectCount() {
        return collectCount;
    }

    public void setCollectCount(Integer collectCount) {
        this.collectCount = collectCount;
    }

    public List<String> getMediaList() {
        return mediaList;
    }

    public void setMediaList(List<String> mediaList) {
        this.mediaList = mediaList;
        
        // 如果设置了mediaList，同步更新media字段
        if (mediaList != null) {
            try {
                // 使用Jackson或其他JSON库转换
                com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
                this.media = mapper.writeValueAsString(mediaList);
            } catch (Exception e) {
                // 转换失败，忽略
            }
        }
    }
}
